package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.param.ReceptionParam;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-05-31 20:47
 */
@Api(tags = "后台管理系统[留言]")
@RequestMapping("/admin")
@RestController
public class MessageController {

    @Autowired
    private MessageService messageService;

    @SystemLog(notes = "获取留言列表{后台管理系统}")
    @ApiOperation(value = "获取留言列表接口")
    @GetMapping("/messages")
    public ResponseResult getMessages(@RequestParam("current")Integer current,
                                      @RequestParam("size")Integer size,
                                      @RequestParam(value = "isReview",required = false) Integer isReview,
                                      @RequestParam(value = "keywords",required = false)String keywords){
        return messageService.getMessages(current,size,isReview,keywords);
    }

    @SystemLog(notes = "删除留言列表(物理){后台管理系统}")
    @ApiOperation(value = "删除留言列表接口",notes = "物理删除留言列表")
    @DeleteMapping("/messages")
    public ResponseResult deleteMessage(@RequestBody Integer[] messageIdList){
        return messageService.deleteMessage(messageIdList);
    }


    @SystemLog(notes = "更新留言审核状态{后台管理系统}")
    @ApiOperation(value = "更新留言审核状态接口", notes = "更新留言审核状态 { 根据评论ID 、 isReview 审核0/通过1 }")
    @PutMapping("/messages/review")
    public ResponseResult updateMessage(@RequestBody ReceptionParam receptionParam){
        return messageService.updateMessage(receptionParam);
    }
}
